package com.example.monitor.model.DTO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor  // 添加无参构造
@AllArgsConstructor // 添加全参构造
public class Result<T> {
    private int code;
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<>(200, "成功", data);
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(400, message, null);
    }

    public static <T> Result<T> error(String message, T data) {
        return new Result<>(400, message, data);
    }

    // 可选：添加其他状态码的快捷方法
    public static <T> Result<T> of(int code, String message, T data) {
        return new Result<>(code, message, data);
    }
}
